home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / LocationEditor.cpp < prev    next >
Text File  |  1997-02-20  |  4KB  |  144 lines

  1. /*
  2.  *  File:       LocationEditor.cpp
  3.  *  Summary:       A view that knows how to edit a pane's location.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    11/24/96    JDJ        Created
  12.  */
  13.  
  14. #include "LocationEditor.h"
  15.  
  16. #include <ZTextBox.h>
  17.  
  18.  
  19. // ===================================================================================
  20. //    class CEditLocationCommand
  21. // ===================================================================================
  22.  
  23. //---------------------------------------------------------------
  24. //
  25. // CEditLocationCommand::~CEditLocationCommand
  26. //
  27. //---------------------------------------------------------------
  28. CEditLocationCommand::~CEditLocationCommand()
  29. {
  30. }
  31.  
  32.  
  33. //---------------------------------------------------------------
  34. //
  35. // CEditLocationCommand::CEditLocationCommand
  36. //
  37. //---------------------------------------------------------------
  38. CEditLocationCommand::CEditLocationCommand(TPane* pane, const SPaneInfo& oldInfo, const SPaneInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  39. {
  40. }
  41.  
  42.  
  43. //---------------------------------------------------------------
  44. //
  45. // CEditLocationCommand::UpdatePane
  46. //
  47. //---------------------------------------------------------------
  48. void CEditLocationCommand::UpdatePane(const SPaneInfo& info)
  49. {
  50.     mPane->SetLocation(info.loc);
  51.     mPane->SetSize(info.size);
  52. }
  53.  
  54. #pragma mark -
  55.  
  56. // ===================================================================================
  57. //    CLocationEditor
  58. // ===================================================================================
  59.  
  60. static TReanimatorRegister<CLocationEditor> sLocationEditorRegistrar;
  61.  
  62. //---------------------------------------------------------------
  63. //
  64. // CLocationEditor::~CLocationEditor
  65. //
  66. //---------------------------------------------------------------
  67. CLocationEditor::~CLocationEditor()
  68. {
  69. }
  70.  
  71.  
  72. //---------------------------------------------------------------
  73. //
  74. // CLocationEditor::CLocationEditor
  75. //
  76. //---------------------------------------------------------------
  77. CLocationEditor::CLocationEditor(TView* superView) : Inherited(superView)
  78. {
  79. }
  80.  
  81.  
  82. //---------------------------------------------------------------
  83. //
  84. // CLocationEditor::Create                                [static]
  85. //
  86. //---------------------------------------------------------------
  87. MReanimatable* CLocationEditor::Create(MReanimatable* parent)
  88. {
  89.     return new CLocationEditor(dynamic_cast<TView*>(parent));
  90. }
  91.  
  92.  
  93. //---------------------------------------------------------------
  94. //
  95. // CLocationEditor::GetEditorInfo        
  96. //
  97. //---------------------------------------------------------------
  98. SPaneInfo CLocationEditor::GetEditorInfo() const
  99. {
  100.     SPaneInfo info;
  101.     
  102.     TTextBox* textBox = nil;
  103.         
  104.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Left"));
  105.     info.loc.h = textBox->GetValue();
  106.     
  107.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Top"));
  108.     info.loc.v = textBox->GetValue();
  109.     
  110.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Width"));
  111.     info.size.width = textBox->GetValue();
  112.     
  113.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Height"));
  114.     info.size.height = textBox->GetValue();
  115.     
  116.     return info;
  117. }
  118.  
  119.  
  120. //---------------------------------------------------------------
  121. //
  122. // CLocationEditor::SetEditorInfo
  123. //
  124. //---------------------------------------------------------------
  125. void CLocationEditor::SetEditorInfo(const SPaneInfo& info)
  126. {
  127.     TTextBox* textBox = nil;
  128.     
  129.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Left"));
  130.     textBox->SetValue(info.loc.h);
  131.     
  132.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Top"));
  133.     textBox->SetValue(info.loc.v);
  134.     
  135.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Width"));
  136.     textBox->SetValue(info.size.width);
  137.     
  138.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Height"));
  139.     textBox->SetValue(info.size.height);
  140. }
  141.  
  142.  
  143.  
  144.